package heven.holt.wan.android.loading.delegate

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.navigation.findNavController
import heven.holt.library.loading.LoadingStateView
import heven.holt.wan.android.R
import heven.holt.wan.android.databinding.LayoutDecorBackgroundTitleBackBinding
import javax.inject.Inject

class BackgroundTitleDecorViewDelegate @Inject constructor() :
    LoadingStateView.DecorViewDelegate() {

    override fun onCreateDecorView(inflater: LayoutInflater): View {
        val binding = LayoutDecorBackgroundTitleBackBinding.inflate(inflater)
        binding.back.setOnClickListener {
            it.findNavController().navigateUp()
        }
        return binding.root
    }

    override fun getContentParent(decorView: View): ViewGroup =
        decorView.findViewById(R.id.back_ground_container)
}